package com.googlecode.bpmcenter.identity;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

import com.googlecode.bpmcenter.util.SecurityUtil;

public class BPMCenterAssignmentHandler implements TaskListener {

  private static final long serialVersionUID = 7652257312713631321L;

	@Override
	 public void notify(DelegateTask delegateTask) {
		
		String taskName = delegateTask.getName();
		
		String currentUser = SecurityUtil.getCurrentUsername();
		System.out.println(currentUser);
		
		if ("PlanejarExecucao".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user2");
		} else if ("AprovarPlanejamento".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user1");
		} else if ("ReceberPecas".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user2");
		} else if ("FotografarPecas".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user1");
		} else if ("TratarImagens".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user2");
		} else if ("DiagramarTags".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user1");
		} else if ("EncerrarOrdemServico".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user2");
		} else if ("EnviarPecas".equalsIgnoreCase(taskName)){
			delegateTask.setAssignee("user1");
		}
		
  }

}
